package com.px.auditRecord.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.px.auditRecord.domain.ForRecordDrone;
import com.px.auditRecord.service.IForRecordDroneService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.px.framework.aes.AesSecurityParameter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.enums.BusinessType;
import com.px.auditRecord.domain.AuditRecordRoutes;
import com.px.auditRecord.service.IAuditRecordRoutesService;
import com.px.common.utils.poi.ExcelUtil;
import com.px.common.core.page.TableDataInfo;

/**
 * 航线审核表Controller
 * 
 * @author WRJ
 * @date 2024-08
 */
@Api("航线审核表")
@RestController
@RequestMapping("/auditRecord/routes")
public class AuditRecordRoutesController extends BaseController
{
    @Autowired
    private IAuditRecordRoutesService auditRecordRoutesService;

    @Autowired
    private IForRecordDroneService forRecordDroneService;

    /**
     * 查询航线审核表列表
     */
    @ApiOperation("查询航线审核表列表")
    @PreAuthorize("@ss.hasPermi('auditRecord:routes:query')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(AuditRecordRoutes auditRecordRoutes)
    {
        startPage();
        List<AuditRecordRoutes> list = auditRecordRoutesService.selectAuditRecordRoutesList(auditRecordRoutes);
        return getDataTable(list);
    }

    /**
     * 导出航线审核表列表
     */
    @ApiOperation("导出航线审核表列表")
    @PreAuthorize("@ss.hasPermi('auditRecord:routes:query')")
    @Log(title = "航线审核表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter(outEncode = false)
    public void export(HttpServletResponse response, AuditRecordRoutes auditRecordRoutes)
    {
        List<AuditRecordRoutes> list = auditRecordRoutesService.selectAuditRecordRoutesList(auditRecordRoutes);
        ExcelUtil<AuditRecordRoutes> util = new ExcelUtil<AuditRecordRoutes>(AuditRecordRoutes.class);
        util.exportExcel(response, list, "航线审核表数据");
    }

    /**
     * 获取航线审核表详细信息
     */
    @ApiOperation("获取航线审核表详细信息")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(auditRecordRoutesService.selectAuditRecordRoutesById(id));
    }

    /**
     * 新增航线审核表
     */
    @ApiOperation("新增航线审核表")
    @PreAuthorize("@ss.hasPermi('auditRecord:routes:edit')")
    @Log(title = "航线审核表", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody AuditRecordRoutes auditRecordRoutes)
    {
        return toAjax(auditRecordRoutesService.insertAuditRecordRoutes(auditRecordRoutes));
    }

    /**
     * 修改航线审核表
     */
    @ApiOperation("修改航线审核表")
    @PreAuthorize("@ss.hasPermi('auditRecord:routes:edit')")
    @Log(title = "航线审核表", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody AuditRecordRoutes auditRecordRoutes)
    {
        return toAjax(auditRecordRoutesService.updateAuditRecordRoutes(auditRecordRoutes));
    }

    /**
     * 删除航线审核表
     */
    @ApiOperation("删除航线审核表")
    @PreAuthorize("@ss.hasPermi('auditRecord:routes:remove')")
    @Log(title = "航线审核表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(auditRecordRoutesService.deleteAuditRecordRoutesByIds(ids));
    }

    /**
     * 查询航线审核表列表
     */
    @ApiOperation("个人查询航线审核表列表")
    @GetMapping("/flightList")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo flightList(AuditRecordRoutes auditRecordRoutes)
    {
        startPage();
        auditRecordRoutes.setCreateBy(getUserId().toString());
        List<AuditRecordRoutes> list = auditRecordRoutesService.selectAuditRecordRoutesList(auditRecordRoutes);
        return getDataTable(list);
    }

    /**
     * 新增航线审核表
     */
    @ApiOperation("个人新增航线审核表")
    @PostMapping("/flightAdd")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult flightAdd(@RequestBody AuditRecordRoutes auditRecordRoutes)
    {
        return toAjax(auditRecordRoutesService.insertAuditRecordRoutes(auditRecordRoutes));
    }

    @ApiOperation("获取航线设备列表")
    @GetMapping(value = "/getDroneList")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo getDrone(AuditRecordRoutes auditRecordRoutes)
    {
        startPage();
        List<ForRecordDrone> list = forRecordDroneService.getDroneListByRoutesId(auditRecordRoutes.getId());
        return getDataTable(list);
    }

}
